package com.yun.zf.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yun.zf.common.admin.dto.house.DocumentCountDto;
import com.yun.zf.common.admin.model.house.DoucumentInfoMo;
import com.yun.zf.common.app.domain.ZfHouseDocumentInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ZfHouseDocumentInfoMapper extends BaseMapper<ZfHouseDocumentInfo> {

    @Select("<script>" +
            " SELECT id did ,  doc.path ,doc.url FROM zf_house_document_info doc WHERE doc.type=#{type} and doc.basic_id=#{basicId}  and doc.city_code=#{cityCode} and doc.province_code=#{provinceCode} " +
            "</script>")
    public List<DoucumentInfoMo> getDocuments(Long basicId, Long provinceCode, Long cityCode,int type);

    @Select("<script>" +
            " SELECT count(1) cn,type from zf_house_document_info doc  WHERE doc.basic_id=#{basicId} and doc.city_code=#{cityCode} and doc.province_code=#{provinceCode} GROUP BY type " +
            "</script>")
    public List<DocumentCountDto> getCountByType(Long basicId, Long provinceCode, Long cityCode);
}
